﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace admin.cyt369.com.Models.Orgs
{
    public class OrgPositionTree : Admin.CYT369.Com.DAL.Domains.Position
    {
        public OrgPositionTree(Admin.CYT369.Com.DAL.Domains.Position position)
        {
            this.NodeType = "POS";
            this.Id = position.Id;
            this.OrgID = position.OrgID;
            this.DepartmentID = position.DepartmentID;
            this.Code = position.Code;
            this.Name = position.Name;
            this.Critical = position.Critical;
            this.Description = position.Description;
            this.Comment = position.Comment;
            this.Enable = position.Enable;
            this.iconCls = "fa fa-circle-o";
        }

        public OrgPositionTree(Admin.CYT369.Com.DAL.Domains.Organization organization)
        {
            this.NodeType = "ORG";
            this.Id = organization.Id * OrgTreeConvert.ConvertVal;
            this.OrgID = organization.Id;
            this.DepartmentID = organization.Id;
            this.Name = string.Empty;
            this.TempDepartmentName = organization.FullName;
            this.Critical = false;
            this.Description = string.Empty;
            this.Comment = string.Empty;
            this.Enable = false;
        }

        public OrgPositionTree(Admin.CYT369.Com.DAL.Domains.Department department)
        {
            this.NodeType = "DEPT";
            this.Id = department.Id * -OrgTreeConvert.ConvertVal;
            this.OrgID = department.OrgID;
            this.DepartmentID = department.Id;
            this.Name = string.Empty;
            this.TempDepartmentName = department.FullName;
            this.Critical = false;
            this.Description = string.Empty;
            this.Comment = string.Empty;
            this.Enable = false;
        }

        public int id {
            get {
                return this.Id;
            }
        }

        public int? parentId {
            get { return this.OrgID+this.DepartmentID; }
        }

        public string text {
            get { return this.Name; }
        }

        public string TempDepartmentName {
            get;set;
        }

        public string iconCls { get; set; }

        public string state { get; set; }

        public string NodeType { get; set; }

        public List<admin.cyt369.com.Models.Orgs.OrgPositionTree> children { get; set; }

    }
}
